"use strict";
var re_channel = "",
	re_cid = "";

function FINUtil(t, a) {
	re_channel = t;
	re_cid = a;

	function e() {
		return(65536 * (1 + Math.random()) | 0).toString(16).substring(1)
	}
	this.isrepeatUrl = '/rest/native/api/transfer/call/isrepeat/'
	this.channelId = t, this.customerId = a, this.method = "post", this.requestid = e() + e() + "-" + e() + "-" + e() + "-" + e() + "-" + e() + e() + e(), this.smallAgents = "NWD|HDW|PP_DAI|CRF|JFDD", this.protocol = "https:" === window.location.protocol ? "https://" : "http://", this.domain = "http://cdn.duoweijr.cn/global/js/finance/fapi.duoweijr.cn", this.baseAction = this.protocol + this.domain + "/rest/load/api/post", this.activiteUrl = this.protocol + this.domain + "/rest/native/api/transfer/call/json", this.activiteCallbackName = "cbfName", this.smallUrl = this.protocol + this.domain + "/rest/load/api/mutil/post", this.smallSimUrl = this.protocol + this.domain + "/rest/load/api/mutil_sim/post", this.simUrl = this.protocol + this.domain + "/rest/native/api/transfer/call/simjson", this.agentUrl = this.protocol + this.domain + "/rest/load/api/", this.agreeInsUrl = this.protocol + this.domain + "/rest/native/ins/api/call/json", this.action = this.baseAction, this.activiteParaName = "p", this.paraAgentKey = "agentkey", this.activiteKey = "670a0be4198343e7019bce4cffa5db78", this.data = {}, this.fromUrl = window.location.href, this.referrer = document.referrer, this.dataRange = {
		phoneno: {
			require: !0,
			range: [],
			format: /^1[34578]\d{9}$/
		},
		name: {
			require: !0,
			range: [],
			format: /^[\u4e00-\u9fa5]{2,4}$/
		},
		money: {
			require: !0,
			range: [],
			format: /^[1-9]\d*$/
		},
		userid: {
			require: !1,
			range: [],
			format: ""
		},
		account: {
			require: !1,
			range: [],
			format: ""
		},
		sex: {
			require: !1,
			range: [],
			format: ""
		},
		loanType: {
			require: !1,
			range: [],
			format: ""
		},
		loanTime: {
			require: !1,
			range: [],
			format: ""
		},
		province: {
			require: !1,
			range: [],
			format: ""
		},
		city: {
			require: !0,
			range: [],
			format: /^[\u4e00-\u9fa5]{2,10}$/
		},
		area: {
			require: !1,
			range: [],
			format: ""
		},
		plantform: {
			require: !1,
			range: [],
			format: ""
		},
		education: {
			require: !1,
			range: [],
			format: ""
		},
		profession: {
			require: !1,
			range: [],
			format: /(^[0|1|2]?$)|(^[9]{2}$)/
		},
		socialSecurity: {
			require: !1,
			range: [],
			format: /^[0|1]?$/
		},
		housingFund: {
			require: !1,
			range: [],
			format: /^[0|1]?$/
		},
		housingType: {
			require: !1,
			range: [],
			format: /^[1|2|3]?$/
		},
		hasCar: {
			require: !1,
			range: [],
			format: /^[1|2|3]?$/
		},
		creditSituation: {
			require: !1,
			range: [],
			format: /^[1|2|3]?$/
		},
		backUrl: {
			require: !1,
			range: [],
			format: /^(http|https):\/\/[a-z|A-Z|0-9|.|_|\-]{1,}.[a-z|A-Z|0-9|.|_|\-]{1,}[a-z|A-Z|0-9|.|=|\/|_|\-|\?|\&|\%|\{|\}|\[|\]|:]{0,}/
		},
		ip: {
			require: !1,
			range: [],
			format: ""
		},
		birthday: {
			require: !1,
			range: [],
			format: ""
		},
		idCard: {
			require: !1,
			range: [],
			format: /^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/
		},
		income: {
			require: !1,
			range: [],
			format: ""
		},
		insurance: {
			require: !1,
			range: [],
			format: ""
		},
		info: {
			require: !1,
			range: [],
			format: ""
		},
		paytype: {
			require: !1,
			range: [],
			format: ""
		},
		worklong: {
			require: !1,
			range: [],
			format: ""
		},
		acceptsafety: {
			require: !1,
			range: [],
			format: ""
		},
		lifeInsurance: {
			require: !1,
			range: [],
			format: ""
		},
		auditBy: {
			require: !1,
			range: [],
			format: ""
		}
	}, this.fixedData = {
		requestid: {
			require: !0,
			range: [],
			format: ""
		},
		referrer: {
			require: !0,
			range: [],
			format: ""
		},
		channel: {
			require: !0,
			range: [],
			format: ""
		},
		fromUrl: {
			require: !0,
			range: [],
			format: ""
		},
		cid: {
			require: !0,
			range: [],
			format: ""
		}
	}, this.init()
}

function isNullValue(t) {
	if(void 0 === t) return !0;
	if(void 0 === t) return !0;
	var a = t + "";
	return "" === (a = a.replace(/(^\s*)|(\s*$)/g, ""))
}
FINUtil.prototype.init = function() {}, FINUtil.prototype.createFormAndSubmit = function() {
	this.createFormData();
	var t = $("<form id='ec_findatasubmitform' method='" + this.method + "'></form>");
	t.attr({
		action: this.action + "?r=" + Math.random()
	});
	var a;
	$.each(this.data, function(e, i) {
		(a = $("<input type='hidden'>")).attr({
			name: e
		}), a.val(i), t.append(a)
	}), t.appendTo("body").submit()
}, FINUtil.prototype.createFormData = function() {
	this.data.channel = this.channelId, this.data.cid = this.customerId, this.data.requestid = this.requestid, this.data.referrer = this.referrer, this.data.fromUrl = this.fromUrl
}, FINUtil.prototype.submit = function(t) {
	void 0 !== t && (this.data = t), this.checkData() && this.createFormAndSubmit()
}, FINUtil.prototype.submitSingle = function(t) {
	isNullValue(t) || (this.action = this.agentUrl + t + "/post", this.submit())
}, FINUtil.prototype.submitAgents = function() {
	this.appendData("postAgents", this.smallAgents), this.action = this.smallUrl, this.submit()
}, FINUtil.prototype.submitSimAgents = function(t) {
	this.action = this.smallSimUrl, this.appendData("agentkey", t), this.submit()
}, FINUtil.prototype.activiteCall = function(t, a, e) {
	a = submitCallbacka;
	if(this.appendData("plantform", t), this.checkData()) {
		this.createFormData();
		var i = this.activiteUrl + "?" + this.activiteParaName + "=" + encodeURIComponent(this.activiteCryptoData());
		isNullValue(e) || (i += "&agentid=" + e), isNullValue(a) || (i += "&" + this.activiteCallbackName + "=" + 'F.isRepeatFun'), $.ajax({
			type: "get",
			url: i,
			dataType: "jsonp"
		})
	}
}, FINUtil.prototype.activiteSimCall = function(t, a, e) {
	if(this.appendData("plantform", t), this.checkData()) {
		this.createFormData();
		var i = this.simUrl + "?" + this.activiteParaName + "=" + encodeURIComponent(this.activiteCryptoData());
		isNullValue(e) || (i += "&agentkey=" + e), isNullValue(a) || (i += "&" + this.activiteCallbackName + "=" + a), $.ajax({
			type: "get",
			url: i,
			dataType: "jsonp"
		})
	}
}, FINUtil.prototype.activiteCryptoData = function() {
	var t = CryptoJS.enc.Latin1.parse(this.activiteKey),
		a = CryptoJS.enc.Latin1.parse(this.activiteKey),
		e = JSON.stringify(this.data);
	return CryptoJS.AES.encrypt(e, t, {
		iv: a,
		mode: CryptoJS.mode.CBC,
		padding: CryptoJS.pad.ZeroPadding
	}).toString()
}, FINUtil.prototype.checkData = function() {
	var t = this.checkParameter,
		a = this.dataRange;
	return $.each(this.data, function(e, i) {
		if(!t(a, e, i)) return !1
	}), !0
}, FINUtil.prototype.checkParameter = function(dataRange, paraName, paraValue) {
	var dataDefine = dataRange[paraName];
	if(void 0 !== dataDefine && "" !== dataDefine) {
		var reg;
		return dataDefine.require ? isNullValue(dataDefine.format) ? !isNullValue(paraValue) : (reg = dataDefine.format).test(paraValue) : !!isNullValue(dataDefine.format) || (reg = eval(dataDefine.format)).test(paraValue)
	}
}, FINUtil.prototype.appendData = function(t, a) {
	void 0 === t ? delete this.data[t] : this.data[t] = a
}, FINUtil.prototype.appendDataSet = function(t) {
	function getDomian() {
		var _a = window.location.hostname.split('.')
		_a.shift();
		return _a.join(".")
	}
	if("object" == typeof t && t instanceof Array)
		for(var a = 0; a < t.length; a++)
			for(var e in t[a]) "" === t[a][e] || void 0 === t[a][e] || null === t[a][e] || (this.data[e] = t[a][e])
	this.data["domain"] = this.data["_host"] ? this.data["_host"] : getDomian()
}, FINUtil.prototype.clearData = function() {
	this.data = {}
}, FINUtil.prototype.defineDataRange = function(t) {
	this.dataRange = t
}, FINUtil.prototype.agreeIns = function(m, i) {
	if(!isNullValue(m) && !isNullValue(i)) {
		var i = this.agreeInsUrl + "?phoneno=" + m + "&insurance=" + i;
		$.ajax({
			type: "get",
			url: i,
			dataType: "jsonp"
		})
	}
};

FINUtil.prototype.isRepeatFun = function(res) {
	console.log('提交返回值', res)
	if(res.code == "1") {
		window.location.href = res.data
	} else {
		var mobile = $("#mobile2").val() ? $("#mobile2").val() : $("#mobile").val();
		var n = this.protocol + this.domain + this.isrepeatUrl + "?phoneno=" + mobile;
		$.ajax(n, {
			method: "GET",
			dataType: "json",
			success: isRepeatFunCallBack
		})
	}
}

function isRepeatFunCallBack(str) {
	console.log('重复回调', str)
	str ? getTimer() : submitCallbacka();
}

function setSubUrl(type) {
	var _url = setCorrespondingSubUrl(window.location.host) + "/daikuan/new10/page3/index3/index.html?"
	switch(type) {
		case "30919":
			return _url;
		default:
			return "https://www.tongchengfs.cn/daikuan/new10/page3/index3/index.html?";
	}
}

function noback() {
	window.addEventListener('popstate', function() {
		window.location.href = window.location.href
	});
}

function getTimer() {
	//	var myDate = new Date();
	//	var nowHours = myDate.getHours();
	//	var nowMinute = myDate.getMinutes();
	//	if(nowHours == 9||nowHours == 10|| (nowHours == 11 && nowMinute <= 30)) {
	//	if(nowHours >= 7 && nowHours < 11) {
	//		window.location.href = "https://gateway.duoweijr.cn/h5spread/landpage/2?channel=yktg-1"
	//	} else {
	//		window.location.href = setRepeatSubUrl(window.location.host)
	//	}
	//	window.location.href = setRepeatSubUrl(window.location.host)
	if(re_channel === "EC-JRTT" || re_channel === "EC-024") {
		window.location.href = setRepeatSubUrlB(window.location.host)
	} else {
		window.location.href = setRepeatSubUrl(window.location.host)
	}
}

function getQueryStringB(n) {
	var e = new RegExp("(^|&)" + n + "=([^&]*)(&|$)", "i"),
		r = window.location.search.substr(1).match(e);
	return null !== r ? unescape(r[2]) : null
}

function compile(code) {
	var c = String.fromCharCode(code.charCodeAt(0) + code.length);
	for(var i = 1; i < code.length; i++) {
		c += String.fromCharCode(code.charCodeAt(i) + code.charCodeAt(i - 1));
	}
	return escape(c);
}

function uncompile(code) {
	code = unescape(code);
	var c = String.fromCharCode(code.charCodeAt(0) - code.length);
	for(var i = 1; i < code.length; i++) {
		c += String.fromCharCode(code.charCodeAt(i) - c.charCodeAt(i - 1));
	}
	return c;
}

function submitCallbacka(_data) {
	var tzurl = setSubUrl("30919");
	var data = compile(JSON.stringify(getSubmitData()));
	tzurl = tzurl + "data=" + data;
	tzurl = tzurl + "&cid=" + re_cid;
	tzurl = tzurl + "&channel=" + re_channel;
	tzurl = tzurl + "&bm=" + getQueryStringB("bm");
	window.location.href = tzurl;
}

function setCorrespondingSubUrl(url) { // 页面提交链接 前半部分
	var _url = url;
	if(_url.indexOf("tongchengfs") != -1) {
		return "https://www.tongchengfs.cn"
	} else if(_url.indexOf("duoweijr") != -1) {
		return "https://www.duoweijr.cn"
	} else if(_url.indexOf("dmqjr") != -1) {
		return "https://www.dmqjr.cn"
	} else if(_url.indexOf("xiaozdai") != -1) {
		return "https://yksq.xiaozdai.com"
	} else if(_url.indexOf("zhongloan") != -1) {
		return "https://yksq.zhongloan.com"
	} else if(_url.indexOf("wenddfin") != -1) {
		return "https://www.wenddfin.cn"
	} else if(_url.indexOf("ecsage") != -1) {
		return "https://m.ecsage.cn"
	} else if(_url.indexOf("shanshengjr") != -1) {
		return "https://www.shanshengjr.cn"
	} else if(_url.indexOf("ykfazhan") != -1) {
		return "https://www.ykfazhan.cn"
	} else if(_url.indexOf("http://cdn.duoweijr.cn/global/js/finance/jrfazh.cn") != -1) {
		return "https://www.jrfazh.cn"
	} else if(_url.indexOf("jrfazhan") != -1) {
		return "https://www.jrfazhan.cn"
	} else if(_url.indexOf("xxiaoedaik") != -1) {
		return "https://www.xxiaoedaik.cn"
	} else {
		console.log("跳转错误！");
		return "https://www.tongchengfs.cn"
	}
}

function setRepeatSubUrl(url) { // 重复用户跳转链接
	var _url = url;
	if(_url.indexOf("tongchengfs") != -1) {
		return "https://ykdc.tongchengfs.cn/ "
	} else if(_url.indexOf("duoweijr") != -1) {
		return "https://ykdc.duoweijr.cn/"
	} else if(_url.indexOf("dmqjr") != -1) {
		return "https://ykdc.dmqjr.cn/"
	} else if(_url.indexOf("xiaozdai") != -1) {
		return "https://ykdc.tongchengfs.cn/"
	} else if(_url.indexOf("zhongloan") != -1) {
		return "https://ykdc.tongchengfs.cn/"
	} else if(_url.indexOf("wenddfin") != -1) {
		return "https://ykdc.wenddfin.cn"
	} else if(_url.indexOf("ecsage") != -1) {
		return "https://ykdc.ecsage.cn/"
	} else if(_url.indexOf("shanshengjr") != -1) {
		return "https://ykdc.shanshengjr.cn/"
	} else if(_url.indexOf("ykfazhan") != -1) {
		return "https://ykdc.ykfazhan.cn/"
	} else if(_url.indexOf("jrfazh") != -1) {
		return "https://ykdc.jrfazh.cn/"
	} else {
		console.log("跳转错误！");
		return "https://ykdc.tongchengfs.cn/"
	}
}

function setRepeatSubUrlB(url) { // EC-JRTT、EC-024重复用户跳转链接
	var _url = url;
	if(_url.indexOf("tongchengfs") != -1) {
		return "https://www.tongchengfs.cn/daikuan/daichao/new09/"
	} else if(_url.indexOf("duoweijr") != -1) {
		return "https://www.duoweijr.cn/daichao/new09/"
	} else if(_url.indexOf("dmqjr") != -1) {
		return "https://www.dmqjr.cn/daikuan/daichao/new09/"
	} else if(_url.indexOf("xiaozdai") != -1) {
		return "https://yksq.xiaozdai.com/daichao/new09/"
	} else if(_url.indexOf("zhongloan") != -1) {
		return "https://yksq.zhongloan.com/daikuan/daichao/new09/"
	} else if(_url.indexOf("wenddfin") != -1) {
		return "https://www.wenddfin.cn/daichao/new09/"
	} else if(_url.indexOf("ecsage") != -1) {
		return "https://m.ecsage.cn/daichao/new09/"
	} else if(_url.indexOf("shanshengjr") != -1) {
		return "https://www.shanshengjr.cn/daichao/new09/"
	} else if(_url.indexOf("ykfazhan") != -1) {
		return "https://www.ykfazhan.cn/daichao/new09/"
	} else if(_url.indexOf("http://cdn.duoweijr.cn/global/js/finance/jrfazh.cn") != -1) {
		return "https://www.jrfazh.cn/daichao/new09/"
	} else if(_url.indexOf("jrfazhan") != -1) {
		return "https://www.jrfazhan.cn/daichao/new09/"
	} else if(_url.indexOf("xxiaoedaik") != -1) {
		return "https://www.xxiaoedaik.cn/daichao/new09/"
	} else {
		console.log("跳转错误！");
		return "https://www.tongchengfs.cn/daikuan/daichao/new09/"
	}
}